﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Security.Cryptography;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.IO;
/// <summary>
/// Summary description for DatabaseFunctions
/// All db utilities will be placed here
/// </summary>
public class DatabaseFunctions
{
	public DatabaseFunctions()
	{
	}

    public static string GetConnectionString()
    {
        System.Configuration.Configuration rootWebConfig =
                System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/OfficeOnline");

        System.Configuration.ConnectionStringSettings connString;

        connString = rootWebConfig.ConnectionStrings.ConnectionStrings["db_OfficeConnectionString"];

        return connString.ToString();
    }

    public static string MD5Encode(string input)
    {
        byte[] hashDataByes;

        UTF8Encoding encoder = new UTF8Encoding();

        MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();

        hashDataByes = md5Hasher.ComputeHash(encoder.GetBytes(input));

        StringBuilder s = new StringBuilder();

        foreach (byte b in hashDataByes)
        {
            s.Append(b.ToString("x2").ToLower());
        }

        return s.ToString();
    }

  

    
}
